<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			* {
				margin: 0;
				padding: 0;
			}
			
			html,
			body {
				width: 100%;
				height: 100%;
			}
			
			body {
				background: #000;
				overflow: hidden;
			}
		</style>
	</head>

	<body>
		<script src="../public.js"></script>
		<script>
			function FireWorks(x, y) {
				this.x = x
				this.y = y
				var that = this
				this.createFire = function() {
					this.box = document.createElement("div")
					document.body.appendChild(this.box)
					this.box.style.cssText = "height:20px;width:12px;background:#fff;position:absolute;"
					this.box.style.left = this.x + "px"
					this.box.style.top = document.documentElement.clientHeight + "px"
					this.move()
				}
				this.move = function() {
					move(this.box, {
						top: this.y
					}, function() {
						document.body.removeChild(that.box); 
						that.createFrag();
					});
				}
				this.createFrag = function(){
					for(var i=0;i<tool.ranNum(80,100);i++){
						this.frag = document.createElement("div")
						this.frag.style.cssText = 'width:5px;height:5px;background:rgb('+tool.ranNum(0,255)+','+tool.ranNum(0,255)+','+tool.ranNum(0,255)+');position:absolute;left:'+this.x+'px;top:'+this.y+'px;';
						document.body.appendChild(this.frag);
						this.boom(this.frag);
					}
				}
				this.boom = function(obj){
					var speedx=parseInt((Math.random()>0.5?-1:1) * tool.ranNum(1,15));
					var speedy=parseInt((Math.random()>0.5?-1:1) * tool.ranNum(1,15));
					var originX=this.x;
					var originY=this.y;
					obj.timer=setInterval(function(){
						originX+=speedx;
						originY+=speedy++;
						if(originY>=document.documentElement.clientHeight){
							clearInterval(obj.timer);
							document.body.removeChild(obj)
						}
						obj.style.left=originX+'px';
						obj.style.top=originY+'px';
						
					},30);
				}
			}
			document.onclick = function(evt){
				var e = evt || event
				var fireWorks = new FireWorks(e.clientX,e.clientY)
				fireWorks.createFire()
			}
		</script>
	</body>

</html>
